/*
 *
 * @Author: mikey.zhaopeng
 * @Date:   2016-01-14 16:10:52
 * @Last Modified by:   mikey.zhaopeng
 * @Last Modified time: 2016-07-13 15:54:12
 */
'use strict';
define([
    '../base/baseView',
    '../bean/version',
], function(
    BaseView,
    versionModel
) {
    function Tools() {
        BaseView.apply(this, arguments);
        var self = this;
        var tpl = '<div id="fmp-footer" class="container-fluid">' +
            '    <footer class="row">' +
            '        <div class="col-sm-6">' +
            '            <span class="txt-color-white">2015 © IM.MK-Facebook Marketing Partner [粤ICP备15052303号-1]</span>' +
            '        </div>' +
            '        <div class="col-sm-6 text-right">' +
            '            <span class="txt-color-white" id="now-version"></span>' +
            '        </div>' +
            '    </footer>' +
            '</div>';

        this.init = function() {
            if (window.pageName == 'home' && !$('#fmp-footer')[0]) {
                $('#layout-main').append(tpl);
                self.$el = $('#fmp-footer');
                self.render();
                self.event();
            }
        }

        this.render = function() {
            var self = this;
            versionModel.queryVersion(function(version) {
                var v = '<a class="btn btn-link" href="#!version">'+I18N.getText('index','currentVersion')+':' + version.version + '</a>';
                $('#now-version').html(v);
            });
        }

        this.event = function() {
            self.$el.off('dblclick').on('dblclick', function(e) {
                if (e.ctrlKey) {
                    window.location.hash = '#!allVersion';
                }
            });

        }

    };
    return new Tools();
});
